// 导入
const mongoose = require("../db/db");
// 配置字段的格式
const UserSchema = mongoose.Schema(
  {
    username: {
      type: String,
    }, // 用户名称
    password: {
      type: String,
      required: true,
    },
    phone: {
      type: Number,
      required: true,
      unique: true, // 唯一, 不可重复
    },
    hospital: String,
    hospitaltype: String,
    describe: String,
    section_office: String,
    headImg: String,
    occupation: String,
    role: {
      type: String,
    },
    createTime: {
      type: Date,
      default: Date.now(),
    }, //创建时间
    lastLoginTime: {
      type: Date,
      default: Date.now(),
    }, //更新时间
    friends: {
      type: Array,
    },
  },
  {
    timestamps: false, // 时间戳
    versionKey: false, // 清除版本信息
  }
);
// 定义模型, 不用写复数
const User = mongoose.model("doctor", UserSchema);
// 输出模型
module.exports = User;
